<?php
/**
 * Created by PhpStorm.
 * User: Duyonggao
 * Date: 2018/1/29 0029
 * Time: 下午 2:03
 */
use kartik\datetime\DateTimePicker;

echo DateTimePicker::widget([
    'name' => 'start',
    'options' => ['placeholder' => '开始时间','id'=>'start'],
    'convertFormat' => true,
    'pluginOptions' => [
        'format' => 'yyyy-M-d H:i:s',
        'startDate' => '2018-01-27 00:00:00',
        'endDate' => date('Y-m-d 23:59:59'),
        'minView'=>1,
        'todayHighlight' => true,
        'language' => 'zh',
    ]
]);
echo DateTimePicker::widget([
    'name' => 'end',
    'options' => ['placeholder' => '结束时间','value'=>date('Y-m-d 23:59:59'),'id'=>'end'],
    'convertFormat' => true,
    'pluginOptions' => [
        'format' => 'yyyy-M-d H:i:s',
        'startDate' => '2018-01-27 00:00:00',
        'endDate' => date('Y-m-d 23:59:59'),
        'minView'=>1,
        'todayHighlight' => true,
        'language' => 'zh',
    ]
]);

$start = date('Y-m-d');
$end = date('Y-m-d');

$path1 = \yii\helpers\Url::to(['test/mobile-out','out'=>1]);
$path2 = \yii\helpers\Url::to(['test/mobile-out','out'=>2]);
$js = <<<Js
$("#start").val('{$start}');
$("#end").val('{$end}');
$("#get").on("click",function(){
    $.get("{$path2}",{start:$("#start").val(),end:$("#end").val()},function(json){
        if(json.code == 200){
            $("#txt").html(json.data);
        }
    },'json');
}).click();
$("#push").on("click",function(){
    var url = '{$path1}&start='+$("#start").val()+'&end='+$("#end").val();
    window.location.href = url;
});
Js;
$this->registerJs($js,\yii\web\View::POS_END);
?>
<button id="get">查询</button>
<button id="push">导出</button>
<div id="txt">

</div>